<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="查看活动">
<style>
    /***费用只显示数字的表单***/
    .time {
        display: inline-block;
        height: 20px;
        line-height: 20px;
        padding: 4px 12px;
        border: 1px solid #cccccc;
        border-radius: 4px;
        vertical-align: middle;
    }

    /***循环的表单设置***/
    .bui-select .bui-select-input {
        width: 350px;
    }

    .button-large {
        font-size: 16px;
    }
</style>
<div class="xm-offline">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="${basepath}/manage/offline/toList">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="editForm" class="form-horizontal" action="${basepath}/manage/offline/reIssueOfflineJson"
                      method="post">
                    <input type="hidden" class="control-text span-width span10" name="id" value="${e.id!}">
                    <input type="hidden" class="control-text span-width span10" name="status" value="1">

                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            活动名称：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="name" value="${e.name!}"
                                   placeholder="请输入活动名称">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            负责人：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principal"
                                   value="${e.principal!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>

                        <div class="controls">
                            <input type="text" class="tel control-text span-width span10" name="principalPhone"
                                   value="${e.principalPhone!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            所在地区：
                        </label>

                        <div class="controls bui-form-group-select" data-type="city">
                            <select class="input-small" name="province" value="${e.province!}">
                                <option>省份</option>
                            </select>&nbsp;&nbsp;
                            <select class="input-small" name="city" value="${e.city!}">
                                <option>城市</option>
                            </select>
                            <select class="input-small" name="area" value="${e.area!}">
                                <option>区</option>
                            </select>
                            <input type="text" class="control-text span-width span8"
                                   name="address" value="${e.address!}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            开始日期：
                        </label>

                        <div class="controls">
                            <input type="text" class="calendar" name="beginTime"
                                   value="${e.beginTime!}" id="beginTime">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            结束日期：
                        </label>

                        <div class="controls">
                            <input type="text" class="calendar" name="endTime"
                                   value="${e.endTime!}" id="endTime">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            活动时段：
                        </label>

                        <div class="controls">
                            <input name="beginTimeFrame" data-rules="{required:true}"
                                   data-messages="{required:'起始时间不能为空'}"
                                   type="time" class="time" value="${e.beginTimeFrame!}" id="beginTimeFrame"><label>
                            &nbsp;-&nbsp;</label>
                            <input name="endTimeFrame" data-rules="{required:true}"
                                   data-messages="{required:'结束时间不能为空'}"
                                   type="time" class="time" value="${e.endTimeFrame!}" id="endTimeFrame">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            周期循环：
                        </label>

                        <div class="controls " id="s1">
                            <input type="hidden" id="hide" name="circulation" value="${e.circulation!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            活动类型：</label>

                        <div class="controls">
                            <select data-rules="{required:true}" name="type" value="${e.type!}" id="type">
                                <option value="1">志愿活动</option>
                                <option value="2">募捐活动</option>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            参与人员：
                        </label>

                        <div class="controls">
                            <select data-rules="{required:true}" name="participant" value="${e.participant!}">
                                <option value="">-请选择-</option>
                                <option value="1">所有志愿者</option>
                                <option value="2">仅限内部志愿者</option>
                                <option value="3">仅限外部志愿者</option>
                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">

                            报名条件：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="conditions"
                                   value="${e.conditions!}"/>
                        </div>
                    </div>
                    <div class="control-group" id="offline-limits">
                        <label class="control-label">
                            参与人数：
                        </label>

                        <div class="controls">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            活动介绍：
                        </label>

                        <div class="controls control-row12" style="height: 350px;initialFrameWidth: 100%;">
                            <textarea type="text" class="input-large" name="content"
                                      id="content">${e.content!}</textarea>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            推送资讯栏：</label>

                        <div class="controls">
                            <select data-rules="{required:true}" name="send" value="${e.send!}" id="send">
                                <option value="">-请选择-</option>
                                <option value="n">否</option>
                                <option value="y">是</option>
                            </select>
                        </div>
                    </div>
                    <div class="centered">
                        <a class="button  button-large  button-success" id="saveBtn">重新发布</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    var editor = UE.getEditor('content');
    var Grid = BUI.Grid;
    var Store = BUI.Data.Store;
    var editForm = new BUI.Form.Form({
        srcNode: '#editForm',
        submitType: 'ajax',
        callback: function (data) {
            if (data.success == true) {
                window.location.href = "${basepath}/manage/offline/toList"
            } else {
                alert(data.message);
            }
        }
    }).render();

    //保存按钮点击事件做处理
    $("#saveBtn").click(function () {
        getType();
    });
    //判断结束日期是否大于开始日期
    function getType() {
        var start = $("#beginTime").val();
        var end = $("#endTime").val();
        var time1 = Date.parse(new Date(start));
        var time2 = Date.parse(new Date(end));
        if (editForm.isValid()) {
            if (time1 <= time2) {
                if ($("#beginTimeFrame").val() < $("#endTimeFrame").val()) {
                    editForm.ajaxSubmit();
                } else {
                    BUI.Message.Alert('结束时段不正确', function () {
                    }, 'info');
                }
            } else {
                BUI.Message.Alert('结束日期不正确', function () {
                }, 'info');
            }
        } else {
            editForm.valid();
        }
    }
    //参与人数
    var limits = "${e.limits!}";
    var limitsHtml = "";
    if (limits == "0") {
        limitsHtml = '<input type="text" class="control-text span-width span10" name="limits " value="不限"  />';

    } else {
        limitsHtml = '<input type="text" class="control-text span-width span10" name="limits " value="' + limits + '"  />';
    }
    document.getElementById("offline-limits").innerHTML += limitsHtml;
    /*--------------------------循环的选项  begin--------------------*/
    BUI.use('bui/select', function (Select) {

        var items = [
                    {text: '周一', value: '周一'},
                    {text: '周二', value: '周二'},
                    {text: '周三', value: '周三'},
                    {text: '周四', value: '周四'},
                    {text: '周五', value: '周五'},
                    {text: '周六', value: '周六'},
                    {text: '周日', value: '周日'}
                ],
                select = new Select.Select({
                    render: '#s1',
                    valueField: '#hide',
                    multipleSelect: true,
                    items: items
                });
        select.render();
    });
    /*--------------------------循环的选项  end--------------------*/
</script>

</@page.pageBase>